package chz.emarket.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import chz.emarket.dao.PersonDao;
import chz.emarket.exception.ServiceException;
import chz.emarket.model.Person;

@Service
public class PersonService {
	
	@Autowired
	private PersonDao personDao;
	
	public Person getPsersonByUserNameAndPassword(String userName, String password) {
		return personDao.getPersonByUserNameAndPassword(userName, password);
	}
	
	public boolean hasMatchUser(String userName, String password) throws ServiceException {
		int matchCount = personDao.getMatchCount(userName, password);
		return matchCount > 0;
	}
	
	public List<Person> getUserList() {
		return personDao.getUserList();
	}
	
	public Person getPersonById(Integer userId) throws ServiceException{
		return personDao.getPersonById(userId);
	}

}
